/**
* ...
* @author Default
* @version 0.1
*/

package bdz.cms.vo{
	import flash.utils.Dictionary;

	public class ContentVO {
		public var id:Number;
		public var title:String;
		public var description:String;
		public var category:Number;
		public var meta:Dictionary;
		public var order:Number;
		public function ContentVO(xm:XML = null) {
			if(xm is XML){
				id = Number(xm.cont_id);
				title = xm.cont_title;
				description = xm.cont_desc;
				category = Number(xm.cat_id);
				order = Number(xm.order);
				try{
					if (xm.meta) {
						parseMeta(xm.meta.child("*"));
					}
				}catch(e:Error){
					
				}
			}
		}
		private function parseMeta(xlist:XMLList):void {
			
			meta = new Dictionary();
			for each(var xm:XML in xlist) {
				var nme:String = xm.name().localName;
				meta[nme] = {};
				meta[nme].id = xm.@id;
				meta[nme].value = xm;
			}
		}
		public function addMeta(key:String, value:*, mid:Number = -1):void{
			
			if(meta == null){
				meta = new Dictionary();
			}
			if(meta[key] == null){
				meta[key] = {};
			}
			if(mid != -1 && meta[key].id == null){
				meta[key].id = mid
			}
			meta[key].value = value;
			
		}
	}
}
	